package vnc.ui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class ICMPbit extends JPanel{

	String[] names;
	Object[] values;
	
	Point LocationBox = new Point(0,0);
	Dimension PaneSize = new Dimension(600,150); 
	
	JLabel jl= new JLabel();
	
	JButton Type;
	JButton Code;
	JButton Checksum;

	public ICMPbit(){
		Type = new JButton("Type");
		Code = new JButton("Code");
		Checksum = new JButton("Checksum");
		
		this.setLayout(null);
		this.setBackground(Color.white);
		
		this.removeBoxBorder(Type);
		this.removeBoxBorder(Code);
		this.removeBoxBorder(Checksum);
		
		Type.setBackground(new Color(0x66,0xcc,0x99));
		Code.setBackground(new Color(0x66,0xcc,0x99));
		Checksum.setBackground(new Color(0x66,0xcc,0x99));
		
		this.add(Type);
		this.add(Code);
		this.add(Checksum);

	}

	public void getInfos(final String[] names,final Object[] values){
			
		jl.setBounds(0, 160, 600, 120);
			this.add(jl);
			Font f = new Font("",Font.BOLD,13);
			jl.setFont(f);
		
			this.names = names;
			this.values = values;
			
			Type.setBounds(LocationBox.x, LocationBox.y,PaneSize.width/4, PaneSize.height/5);
			Type.addActionListener(new ActionListener(){
				public void actionPerformed(ActionEvent arg0) {
					jl.setText(names[0]+" : "+values[0]);
				}
			});
			
			Code.setBounds(LocationBox.x + Type.getWidth(), LocationBox.y,PaneSize.width/4, PaneSize.height/5);
			Code.addActionListener(new ActionListener(){
				public void actionPerformed(ActionEvent arg0) {
					jl.setText(names[1]+" : "+values[1]);
				}
			});
			Checksum.setBounds(LocationBox.x+Code.getX() + Code.getWidth(), LocationBox.y,PaneSize.width/2, PaneSize.height/5);
			Checksum.addActionListener(new ActionListener(){
				public void actionPerformed(ActionEvent arg0) {
					jl.setText(names[2]+" : "+values[2]);
				}
			});
		}
	public static void removeBoxBorder(JButton box){
		box.setBorderPainted(true);
		box.setContentAreaFilled(true);
		box.setDefaultCapable(false);
		box.setFocusPainted(false);
	}
	
	public void getInfos(String[] names, Object[] values, int h) {
		// TODO Auto-generated method stub
		
	}


	public String isProtocol() {
		// TODO Auto-generated method stub
		return "ICMP";
	}


	public void onPane() {
		// TODO Auto-generated method stub
		this.setVisible(true);
	}

	
	public void offPane() {
		// TODO Auto-generated method stub
		this.setVisible(false);
	}

}
